import { sendRequest } from '@/http';

const baseUrl = '/admin/inst';

/**
 * 查询机构部门列表
 * @param departmentName 部门名称（模糊查询）
 * @returns
 */
export const queryInstDepartments = (departmentName: string) => {
  return sendRequest({
    url: `${baseUrl}/queryInstDepartments`,
    method: 'get',
    params: { departmentName },
  });
};

/**
 * 新增机构部门
 * @param department
 * @returns
 */
export const createInstDepartment = (department: {
  name: string;
  parentId?: string;
}) => {
  return sendRequest({
    url: `${baseUrl}/createInstDepartment`,
    method: 'post',
    data: department,
  });
};

/**
 * 编辑机构部门
 * @param department
 * @returns
 */
export const editInstDepartment = (department: {
  id: string;
  name: string;
  parentId?: string;
}) => {
  return sendRequest({
    url: `${baseUrl}/editInstDepartment`,
    method: 'post',
    data: department,
  });
};

/**
 * 删除机构部门
 * @param id 部门ID
 * @returns
 */
export const deleteInstDepartment = (id: string) => {
  return sendRequest({
    url: `${baseUrl}/deleteInstDepartment`,
    method: 'post',
    data: { id },
  });
};
